Component({
    properties: {},
    data: {
        menuItems: [
            { name: '菜单1', active: true },
            { name: '菜单2', active: false },
            { name: '菜单3', active: false }
        ],
        dataItems: [
            { name: '菜单1', content: '这是菜单1的内容', active: true },
            { name: '菜单2', content: '这是菜单2的内容', active: false },
            { name: '菜单3', content: '这是菜单3的内容', active: false }
        ]
    },
    methods: {
        showData(e) {
            var index = e.currentTarget.dataset.index;

            // 更新菜单项的active状态
            var menuItems = this.data.menuItems.map(function (item, i) {
                if (i === index) {
                    item.active = true;
                } else {
                    item.active = false;
                }
                return item;
            });

            // 更新数据项的active状态
            var dataItems = this.data.dataItems.map(function (item, i) {
                if (i === index) {
                    item.active = true;
                } else {
                    item.active = false;
                }
                return item;
            });

            this.setData({
                menuItems: menuItems,
                dataItems: dataItems
            });
        }
    }
});
